home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / pctv3n2.zip / DRIVES.ASM < prev    next >
Assembly Source File  |  1992-04-06  |  3KB  |  58 lines

  1. ;DRIVES.ASM
  2. ;(c) 1991 by Deborah L. Cooper
  3. ;
  4. codesg  segment
  5.         assume  cs:codesg
  6.         org     100h            ;make this a COM program
  7. start:  jmp     start_2         ;skip over data area
  8.  
  9. org_drive       db      0       ;current drive code
  10. got_drive       db      0dh,0ah,'Valid drive: ','$' ;output message
  11.  
  12. ;Get and save the current drive so we can restore it later on
  13. start_2:
  14.         mov     ah,19h          ;get default drive code
  15.         int     21h             ;call dos
  16.         mov     org_drive,al    ;save it (0=A, 1=B, ... )
  17. ;Now go through 1-26 possible drive codes and display the
  18. ;message when we find a valid disk drive
  19. select: mov     ah,0eh          ;select drive function
  20.         mov     dl,0            ;start with Drive A
  21.         int     21h             ;call dos
  22. ;Use function 19h to see if drive actually exists
  23. select_2:
  24.         mov     ah,19h          ;get default disk drive
  25.         int     21h             ;call dos
  26.         cmp     dl,al           ;is it a valid drive?
  27.         je      got_one         ;yes, show the message!
  28. next_drive:
  29.         inc     dl              ;no, prepare to test next one
  30.         cmp     dl,27d          ;maximum 26 possible!
  31.         jae     all_done        ;go if done now
  32.         mov     ah,0eh          ;select drive function
  33.         int     21h             ;call dos
  34.         jmp     select_2        ;and go back to test it
  35. got_one:
  36.         push    dx              ;save our drive number
  37.         mov     dx,offset got_drive ;point DX to message
  38.         mov     ah,09h          ;display string function
  39.         int     21h             ;call dos
  40. ;Show the message with drive letter
  41.         pop     dx              ;recover test drive code
  42.         push    dx              ;save on stack for a minute
  43.         xchg    al,dl           ;put drive code in AL for printing
  44.         add     al,41h          ;convert to ASCII letter
  45.         mov     ah,0eh          ;display byte function
  46.         int     10h             ;call bios
  47.         pop     dx              ;recover our drive number
  48.         jmp     next_drive      ;and go back
  49. ;Now restore our original drive and exit
  50. all_done:
  51.         mov     ah,0eh          ;select drive function
  52.         mov     dl,org_drive    ;original drive code
  53.         int     21h             ;call dos
  54.         mov     ah,4ch          ;terminate program function
  55.         int     21h             ;call dos
  56. codesg  ends
  57.         end     start           ;end of demo!
  58.